import logging

import pymysql

# 数据库配置常量
DB_CONFIG = {
    "host": "localhost",
    "port": 3306,
    "user": "root",
    "password": "root",
    "database": "finance"
}

class comDB:
    def __init__(self):
        self.con = None
        self.cursor = None

    def get_con(self):
        if self.con and self.con.open:
            self.close_con()
        self.con= pymysql.connect(**DB_CONFIG)
        self.cursor = self.con.cursor()
        return self.con,self.cursor


